<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="template.xhtml">
	<ui:define name="content">
	
	<f:metadata>  
	    <f:viewParam name="packageId" value="#{packageDetailsBean.packageId}" /> 
	    <f:viewParam name="code" value="#{packageDetailsBean.code}" />
	    <f:event listener="#{packageDetailsBean.loadData}" type="preRenderView"/>
	</f:metadata> 

	<br />
	<p:fieldset legend="#{packageDetailsBean.pack.name}">  
	    <h:panelGrid columns="2" cellpadding="10">  
	        <p:graphicImage width="200px" value="../images/packages/#{packageDetailsBean.pack.id}.jpg" />  
	        <h:outputText value="#{packageDetailsBean.pack.description}" />  
	    </h:panelGrid>  
	    
        
        <p:tabView>
        	<p:tab title="La località">
        		<h2><h:outputText value="#{packageDetailsBean.pack.location.name} (#{packageDetailsBean.pack.location.nation.name})" /></h2>
        		<h:outputText value="#{packageDetailsBean.pack.location.description}" />
        	</p:tab>
        	<p:tab title="Hotel predefinito">
        		<h:panelGrid columns="2" cellpadding="10"> 
        			<p:graphicImage width="300px" value="../images/hotels/#{packageDetailsBean.pack.hotel.id}.jpg" /> 
				    <h:panelGrid columns="1">
				        <h2><h:outputText value="#{packageDetailsBean.pack.hotel.name}" /></h2>
	        			<h:outputText value="#{packageDetailsBean.pack.hotel.description}" />
        			</h:panelGrid>  
			    </h:panelGrid>
        	</p:tab>
        	<p:tab title="Ecursione predefinita">
        		<h:panelGrid columns="2" cellpadding="10"> 
        			<p:graphicImage width="300px" value="../images/excursions/#{packageDetailsBean.pack.excursion.id}.jpg" /> 
				    <h:panelGrid columns="1">
				        <h2><h:outputText value="#{packageDetailsBean.pack.excursion.name}" /></h2>
        				<h:outputText value="#{packageDetailsBean.pack.excursion.description}" />
        			</h:panelGrid>  
			    </h:panelGrid>	
        	</p:tab>
        </p:tabView>
        
        <h4><h:outputText value="#{packageDetailsBean.pack.extra}" /></h4>
        Clicca sul bottone sottostante per scegliere le date del tuo soggiorno, prenotare i voli ed eventualmente modificare gli elementi predefiniti del pacchetto.<br /><br /> 
        <center><p:button outcome="personalizePackage" value=">> Personalizza e prenota il tuo pacchetto viaggio">  
		    <f:param name="packageId" value="#{packageDetailsBean.packageId}" />  
		</p:button></center>
        
	</p:fieldset>  
	<br /><br />
	
	<p:fieldset legend="Hotel disponibili" collapsed="true" toggleable="true" toggleSpeed="500">
		<p:dataTable var="hot" value="#{packageDetailsBean.availableHotels}"> 
			<p:column headerText="Hotel">
				#{hot.name}
			</p:column>
			<p:column headerText="Prezzo">
				#{hot.reservationInfo}
			</p:column>
			<p:column>
				#{hot.extra}
			</p:column>
			<p:column headerText="Dettagli">
				<center><p:button outcome="hotelDetails" icon="ui-icon-search" title="Visualizza dettagli">  
			    <f:param name="elementId" value="#{hot.id}" />  
			    <f:param name="packageId" value="#{packageDetailsBean.packageId}" />
			</p:button></center>
			</p:column>
		</p:dataTable>
	</p:fieldset>
	<br />
	<p:fieldset legend="Escursioni disponibili" collapsed="true" toggleable="true" toggleSpeed="500">
		<p:dataTable var="exc" value="#{packageDetailsBean.availableExcursions}"> 
			<p:column headerText="Escursione">
				#{exc.name}
			</p:column>
			<p:column headerText="Prezzo">
				#{exc.reservationInfo}
			</p:column>
			<p:column>
				#{exc.extra}
			</p:column>
			<p:column headerText="Dettagli">
				<center><p:button outcome="excursionDetails" icon="ui-icon-search" title="Visualizza dettagli">  
			    <f:param name="elementId" value="#{exc.id}" />  
			    <f:param name="packageId" value="#{packageDetailsBean.packageId}" />
			</p:button></center>
			</p:column>
		</p:dataTable>
	</p:fieldset>
	<br />
	<p:fieldset legend="Voli disponibili" collapsed="true" toggleable="true" toggleSpeed="500">
		<h:panelGrid columns="2"> 
			<p:panel>
				<h3>Voli di andata</h3>
				<p:dataList value="#{packageDetailsBean.flightsTo}" var="f" itemType="disc">  
				Da #{f.airport1.location.name} (#{f.airport1.name}) a #{f.airport2.location.name} (#{f.airport2.name}) 
				con "#{f.company}"<br />#{f.price} euro a passeggero - #{f.extra}<br />
				</p:dataList>
			</p:panel>
			<p:panel>
				<h3>Voli di ritorno</h3>
				<p:dataList value="#{packageDetailsBean.flightsFrom}" var="f" itemType="disc">  
				Da #{f.airport1.location.name} (#{f.airport1.name}) a #{f.airport2.location.name} (#{f.airport2.name}) 
				con "#{f.company}"<br />#{f.price} euro a passeggero - #{f.extra}<br />
				</p:dataList>
			</p:panel>
		</h:panelGrid>
		
	</p:fieldset>
	
	
	</ui:define>
</ui:composition>
</html>